/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package wizard;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;

/**
 *
 * @author afspear
 */
public class Logger {
    
    private String fileString;

    public void setFileString(String fileString) {
        this.fileString = fileString;
    }

    public Logger() {
    }

    public Logger(String file) {
        this.fileString = file; 
    }
    
    private void logToFile(String logString) {
        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        Date date = new Date();
        try {
            FileWriter file = new FileWriter(this.fileString, true);
            BufferedWriter out = new BufferedWriter(file);
            out.write(dateFormat.format(date) + logString + "\n");
            out.close();
        } catch (IOException ex) {
            java.util.logging.Logger.getLogger(Logger.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void logAction(String action, String name1, String name2) {
        logToFile(action + "(" + name1 + ", " + name2 + ")\n");
    }

    public void logString(String string) {
        logToFile(string);
    }

    public void logRole(String name, String role) {
        logToFile(name + " is a " + role + "\n");
    }
}
